/*
 * Event.cpp
 *
 *  Created on: 2012-12-6
 *      Author: yangentao@gmail.com
 */

#include "Event.h"

namespace yet {

Event::Event() {
	event = CreateEvent(0, FALSE, FALSE, 0);
}

Event::~Event() {
	if (event) {
		CloseHandle(event);
	}
}

void Event::notify() {
	SetEvent(event);
}
DWORD Event::wait() {
	return wait(INFINITE);
}
DWORD Event::wait(DWORD timeout) {
	return WaitForSingleObject(event, timeout);
}

} /* namespace yet */
